<?
if(! defined('BASEPATH') ){ exit('Unable to view file.'); }
$sql = $db->Query("SELECT SUM(money) as money FROM transactions");
$row = $db->FetchArray($sql);
$total = $row['money'];
?>
            <div id="page-subheader">
                <div class="wrapper clearfix">
                    <nav id="sub-nav">
                        <ul>
                            <li><a href="index.php">Summary</a></li>
							<li class="active"><a href="index.php?x=sales">Sales</a></li>
                        </ul>
                    </nav>
                </div>
            </div>
        </header>
        
        <section id="content">
            <div class="wrapper">
                <section class="grid_6 first top">
                    <div class="columns">
                        <div class="column grid_6 first">
                            <table class="datatable sortable selectable paginate full">
                                <thead>
                                    <tr>
                                        <th width="25">#</th>
                                        <th>User</th>
                                        <th>Points</th>
                                        <th>Type</th>
										<th>Money</th>
										<th>Date</th>
                                    </tr>
                                </thead>
								<tfoot>
                                    <tr>
                                        <th width="25">#</th>
                                        <th>User</th>
                                        <th>Amount</th>
                                        <th>Type</th>
										<th>Money</th>
										<th>Date</th>
                                    </tr>
                                </tfoot>
                                <tbody>
<?
  $sql = $db->Query("SELECT * FROM `transactions` ORDER BY `date` DESC");
  for($j=1; $tra = $db->FetchArray($sql); $j++)
{
?>	
                                    <tr>
                                        <td><?=$j?></td>
                                        <td><?=$tra['user']?></td>
                                        <td><?=$tra['points']?></td>
                                        <td><?=($tra['type'] == 0 ? 'Coins' : 'Premium')?></td>
                                        <td><?=$tra['money']?>$</td>
										<td><?=$tra['date']?></td>
                                    </tr>
<?}?>
                                </tbody>
                            </table>
                        </div>
                    </div>

                    <div class="clear">&nbsp;</div>

                </section>

                <aside class="grid_2 top">
                    <div class="accordion">
                        <header class="current"><h2>Income</h2></header>
                        <section style="display:block">
                            <dl>
								<dd><font size="2"><b>Total:</b></font> <?=($total == "" ? "0.00" : $total)?> $</dd>
                            </dl>
                        </section>
                    </div>
                </aside>
                <div class="clear"></div>
            </div>
            <div id="push"></div>
        </section>

    </div>
    
    <footer id="page-footer">
        <div id="footer-inner">
            <p class="wrapper">All rights reserved &copy; <a href="http://mafianet.org" target="_blank">MafiaNet</a> <?=date('Y')?></p>
        </div>
    </footer>
</body>
</html>